package com.hong.spring.annotation;

import com.alibaba.fastjson.JSONObject;
import com.hong.spring.common.config.condition.ConfigSystem;
import com.hong.spring.common.entity.ConditionUser7;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Map;

/**
 * @Auther: csh
 * @Date: 2020/7/10 17:38
 * @Description:测试@Conditional
 */
public class ConditionalTest {
    public static void main(String[] args) {
        //从类路径的xm文件载入上下文定义的信息
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigSystem.class);
        String env_system = context.getEnvironment().getProperty("env_system");
        System.out.println("系统为:"+env_system);
        Map <String, ConditionUser7> beansOfType = context.getBeansOfType(ConditionUser7.class);
        System.out.println(JSONObject.toJSONString((beansOfType)));
    }
}
